<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true"><block slot="backText">返回</block>
			<block slot="content">申请加入</block>
		</cu-custom>
		<view class="cs-join-main">
			<view class="cu-bar">
				<view class="action text-blue" @tap="backcs">取消</view>
				<view class="action text-green" @tap="surecs">确定</view>
			</view>
			<view class="cs-join-tips">需要发送验证申请,等待管理员通过审核</view>
			<view class="cs-join-r">
				<textarea class="cs-join-reason" maxlength="-1" v-model="reason"  @input="textareaAInput" placeholder="请输入申请说明"></textarea>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		onLoad(option){
			this.csid = option.csid;
			this.userid=uni.getStorageSync("uid");
			this.openid=uni.getStorageSync('openid');
			console.log("aha:"+this.userid +" --" +this.openid)
			if(this.userid.length<=0 || this.openid.length<=0){
				uni.showModal({
				    title: '提示',
				    content: '您暂未登陆,是否马上登陆',
				    success: function (res) {
				        if (res.confirm) {
							uni.switchTab({
								url:"/pages/tennis/user/index"
							})
				        } else if (res.cancel) {
				           uni.navigateBack({
				           	
				           })
				        }
				    }
				});
				return;
			}
		},
		data() {
			return {
				csid:0,
				reason:"",
				userid:'',
				openid:''
			}
		},
		methods: {
			textareaAInput(e){
				
			},
			backcs(e){
				uni.navigateBack({
					
				})
			},
			surecs(e){
				uni.request({
					url:"https://www.52tennis.cn/Club_Soci/InsertUser_Club",
					header:{
						'Content-Type': 'application/json;charset=UTF-8' //自定义请求头信息
					},
					method:'POST',
					data: {
						clubid:this.csid,
						userid:this.userid,
						reason:this.reason
					},
					success:(data)=> {
						console.log(data);
						if(data.data.result==1){
							
							uni.showModal({
							    title: '提示',
							    content: '申请成功,请等待管理人员审核',
							    success: function (res) {
							        if (res.confirm) {
							            uni.navigateBack({
							            	
							            })
							        } else if (res.cancel) {
							           
							        }
							    }
							});
							
						}else{
							uni.showModal({
							    title: '提示',
							    content: data.data.msg,
							    success: function (res) {
							        if (res.confirm) {
							           uni.navigateBack({
							           	
							           })
							        } else if (res.cancel) {
							           
							        }
							    }
							});
							
						}
					},
				})
			}
		}
	}
</script>

<style>
	.cs-join-tips{
		padding-left: 30rpx;
	}
	.cs-join-r{
		padding: 30rpx;
	}
	.cs-join-reason{
		width: 100%;
		height: 300rpx;
		background-color: white;
		border-radius: 20rpx;
		border:1rpx solid #8799A3;
		padding: 15rpx;
	}
</style>
